var Currency = {
	Detail: {
		init: function() {
			Language.getCurrLanguage();
			Utils.loadJavascriptFile('/application/views/libraries/component/' + language + '.js');
			Utils.loadJavascriptFile('/application/views/libraries/utils/' + language + '.js');
			Utils.loadJavascriptFile('/application/views/module/Currency/' + language + '.js');
			Utils.initAjax();
			
			Currency.Detail.View.init();
		},
		
		View: {
			dataGridPanelContainer: '',
			
			init: function() {
				Currency.Detail.View.dataGridPanelContainer = $('#dataGridPanel #dataGrid');
				Currency.Detail.View.DataGrid.init();
			},
			
			DataGrid: {
				gameAreaCombogridLabelContainer: '',
				gameAreaCombogridInputContainer: '',
				accountValidateboxLabelContainer: '',
				accountValidateboxInputContainer: '',
				roleNameValidateboxLabelContainer: '',
				roleNameValidateboxInputContainer: '',
				currencyTypeComboboxLabelContainer: '',
				currencyTypeComboboxInputContainer: '',
				startDatetimeboxLabelContainer: '',
				startDatetimeboxInputContainer: '',
				endDatetimeboxLabelContainer: '',
				endDatetimeboxInputContainer: '',
				searchButtonContainer: '',

				init: function() {
					Currency.Detail.View.DataGrid.gameAreaCombogridLabelContainer = $('#dataGridPanel #toolbar #gameAreaCombogridLabel');
					Currency.Detail.View.DataGrid.gameAreaCombogridInputContainer = $('#dataGridPanel #toolbar #gameAreaCombogridInput');
					Currency.Detail.View.DataGrid.accountValidateboxLabelContainer = $('#dataGridPanel #toolbar #accountValidateboxLabel');
					Currency.Detail.View.DataGrid.accountValidateboxInputContainer = $('#dataGridPanel #toolbar #accountValidateboxInput');
					Currency.Detail.View.DataGrid.roleNameValidateboxLabelContainer = $('#dataGridPanel #toolbar #roleNameValidateboxLabel');
					Currency.Detail.View.DataGrid.roleNameValidateboxInputContainer = $('#dataGridPanel #toolbar #roleNameValidateboxInput');
					Currency.Detail.View.DataGrid.currencyTypeComboboxLabelContainer = $('#dataGridPanel #toolbar #currencyTypeComboboxLabel');
					Currency.Detail.View.DataGrid.currencyTypeComboboxInputContainer = $('#dataGridPanel #toolbar #currencyTypeComboboxInput');
					Currency.Detail.View.DataGrid.startDatetimeboxLabelContainer = $('#dataGridPanel #toolbar #startDatetimeboxLabel');
					Currency.Detail.View.DataGrid.startDatetimeboxInputContainer = $('#dataGridPanel #toolbar #startDatetimeboxInput');
					Currency.Detail.View.DataGrid.endDatetimeboxLabelContainer = $('#dataGridPanel #toolbar #endDatetimeboxLabel');
					Currency.Detail.View.DataGrid.endDatetimeboxInputContainer = $('#dataGridPanel #toolbar #endDatetimeboxInput');
					Currency.Detail.View.DataGrid.searchButtonContainer = $('#dataGridPanel #toolbar #searchButton');
					Currency.Detail.View.DataGrid.create();
				},
				
				create: function() {
					var width = $(document).width() - 40;
					var height = $(document).height() - 40;
					Currency.Detail.View.dataGridPanelContainer.width(width);
					Currency.Detail.View.dataGridPanelContainer.height(height);
					Currency.Detail.View.dataGridPanelContainer.datagrid({
						fitColumns: false,
						toolbar: '#toolbar',
						columns: [[
							{
								field: 'functionName',
								title: currencyDetailViewDataGridColumnTitle1,
								width: 100,
							},
							{
								field: 'subFunctionName',
								title: currencyDetailViewDataGridColumnTitle2,
								width: 100,
							},
							{
								field: 'changeValue',
								title: currencyDetailViewDataGridColumnTitle3,
								width: 100,
							},
							{
								field: 'surplusValue',
								title: currencyDetailViewDataGridColumnTitle4,
								width: 100,
							},
							{
								field: 'operatorDateTime',
								title: currencyDetailViewDataGridColumnTitle5,
								width: 150,
							},
						]],
						loadFilter: Utils.dataGridLoadFilter,
						pagination: true,
						pageSize: 50,
						pageList: [50, 100, 150, 200],
					});
					Component.Combogrid.GameArea.create(
						Currency.Detail.View.DataGrid.gameAreaCombogridLabelContainer,
						Currency.Detail.View.DataGrid.gameAreaCombogridInputContainer
					);
					Component.Validatebox.Account.create(
						Currency.Detail.View.DataGrid.accountValidateboxLabelContainer,
						Currency.Detail.View.DataGrid.accountValidateboxInputContainer
					);
					Component.Validatebox.RoleName.create(
						Currency.Detail.View.DataGrid.roleNameValidateboxLabelContainer,
						Currency.Detail.View.DataGrid.roleNameValidateboxInputContainer
					);
					Component.Combobox.CurrencyType.create(
						Currency.Detail.View.DataGrid.currencyTypeComboboxLabelContainer,
						Currency.Detail.View.DataGrid.currencyTypeComboboxInputContainer
					);
					Component.Datetimebox.Start.create(
						Currency.Detail.View.DataGrid.startDatetimeboxLabelContainer,
						Currency.Detail.View.DataGrid.startDatetimeboxInputContainer
					);
					Component.Datetimebox.End.create(
						Currency.Detail.View.DataGrid.endDatetimeboxLabelContainer,
						Currency.Detail.View.DataGrid.endDatetimeboxInputContainer
					);
					Currency.Detail.View.DataGrid.searchButtonContainer.linkbutton({
						iconCls: 'icon-search',
						text: currencyDetailViewDataGridToolbarButtonText1,
					});
					Currency.Detail.View.DataGrid.searchButtonContainer.bind(
						'click',
						Currency.Detail.View.DataGrid.doSearch
					);
				},
				
				doSearch: function() {
					Currency.Detail.View.dataGridPanelContainer.datagrid({
						url: '/index.php/Currency/detail/getListData',
						queryParams: {
							gameAreaId: Currency.Detail.View.DataGrid.gameAreaCombogridInputContainer.combogrid('getValue'),
							account: Currency.Detail.View.DataGrid.accountValidateboxInputContainer[0].value,
							roleName: Currency.Detail.View.DataGrid.roleNameValidateboxInputContainer[0].value,
							startDateTime: Currency.Detail.View.DataGrid.startDatetimeboxInputContainer.datetimebox('getValue'),
							endDateTime: Currency.Detail.View.DataGrid.endDatetimeboxInputContainer.datetimebox('getValue'),
							currencyTypeId: Currency.Detail.View.DataGrid.currencyTypeComboboxInputContainer.combobox('getValue'),
						}
					});
				},
			},
		},
	},
	
	Summary: {
		init: function() {
			Language.getCurrLanguage();
			Utils.loadJavascriptFile('/application/views/libraries/component/' + language + '.js');
			Utils.loadJavascriptFile('/application/views/libraries/utils/' + language + '.js');
			Utils.loadJavascriptFile('/application/views/module/Currency/' + language + '.js');
			Utils.initAjax();
			
			Currency.Summary.View.init();
		},
		
		View: {
			dataGridPanelContainer: '',
			
			init: function() {
				Currency.Summary.View.dataGridPanelContainer = $('#dataGridPanel #dataGrid');
				Currency.Summary.View.DataGrid.init();
			},
			
			DataGrid: {
				gameAreaCombogridLabelContainer: '',
				gameAreaCombogridInputContainer: '',
				currencyTypeComboboxLabelContainer: '',
				currencyTypeComboboxInputContainer: '',
				startDateboxLabelContainer: '',
				startDateboxInputContainer: '',
				endDateboxLabelContainer: '',
				endDateboxInputContainer: '',
				searchButtonContainer: '',

				init: function() {
					Currency.Summary.View.DataGrid.gameAreaCombogridLabelContainer = $('#dataGridPanel #toolbar #gameAreaCombogridLabel');
					Currency.Summary.View.DataGrid.gameAreaCombogridInputContainer = $('#dataGridPanel #toolbar #gameAreaCombogridInput');
					Currency.Summary.View.DataGrid.currencyTypeComboboxLabelContainer = $('#dataGridPanel #toolbar #currencyTypeComboboxLabel');
					Currency.Summary.View.DataGrid.currencyTypeComboboxInputContainer = $('#dataGridPanel #toolbar #currencyTypeComboboxInput');
					Currency.Summary.View.DataGrid.startDateboxLabelContainer = $('#dataGridPanel #toolbar #startDateboxLabel');
					Currency.Summary.View.DataGrid.startDateboxInputContainer = $('#dataGridPanel #toolbar #startDateboxInput');
					Currency.Summary.View.DataGrid.endDateboxLabelContainer = $('#dataGridPanel #toolbar #endDateboxLabel');
					Currency.Summary.View.DataGrid.endDateboxInputContainer = $('#dataGridPanel #toolbar #endDateboxInput');
					Currency.Summary.View.DataGrid.searchButtonContainer = $('#dataGridPanel #toolbar #searchButton');
					Currency.Summary.View.DataGrid.create();
				},
				
				create: function() {
					var width = $(document).width() - 40;
					var height = $(document).height() - 40;
					Currency.Summary.View.dataGridPanelContainer.width(width);
					Currency.Summary.View.dataGridPanelContainer.height(height);
					Currency.Summary.View.dataGridPanelContainer.datagrid({
						fitColumns: false,
						toolbar: '#toolbar',
						columns: [[
							{
								field: 'operatorName',
								title: currencySummaryViewDataGridColumnTitle1,
								width: 160,
							},
							{
								field: 'areaNum',
								title: currencySummaryViewDataGridColumnTitle2,
								width: 80,
							},
							{
								field: 'date',
								title: currencySummaryViewDataGridColumnTitle3,
								width: 150,
							},
							{
								field: 'functionId',
								title: currencySummaryViewDataGridColumnTitle8,
								width: 50,
							},
							{
								field: 'functionName',
								title: currencySummaryViewDataGridColumnTitle4,
								width: 150,
							},
							{
								field: 'subFunctionName',
								title: currencySummaryViewDataGridColumnTitle5,
								width: 100,
							},
							{
								field: 'getValue',
								title: currencySummaryViewDataGridColumnTitle6,
								width: 100,
							},
							{
								field: 'costValue',
								title: currencySummaryViewDataGridColumnTitle7,
								width: 100,
							},
						]],
						loadFilter: Utils.dataGridLoadFilter,
						pagination: true,
						pageSize: 50,
						pageList: [50, 100, 150, 200],
					});
					Component.Combogrid.GameArea.create(
						Currency.Summary.View.DataGrid.gameAreaCombogridLabelContainer,
						Currency.Summary.View.DataGrid.gameAreaCombogridInputContainer,
						true
					);
					Component.Combobox.CurrencyType.create(
						Currency.Summary.View.DataGrid.currencyTypeComboboxLabelContainer,
						Currency.Summary.View.DataGrid.currencyTypeComboboxInputContainer
					);
					Component.Datebox.Start.create(
						Currency.Summary.View.DataGrid.startDateboxLabelContainer,
						Currency.Summary.View.DataGrid.startDateboxInputContainer
					);
					Component.Datebox.End.create(
						Currency.Summary.View.DataGrid.endDateboxLabelContainer,
						Currency.Summary.View.DataGrid.endDateboxInputContainer
					);
					Currency.Summary.View.DataGrid.searchButtonContainer.linkbutton({
						iconCls: 'icon-search',
						text: currencySummaryViewDataGridToolbarButtonText1,
					});
					Currency.Summary.View.DataGrid.searchButtonContainer.bind(
						'click',
						Currency.Summary.View.DataGrid.doSearch
					);
				},
				
				doSearch: function() {
					Currency.Summary.View.dataGridPanelContainer.datagrid({
						url: '/index.php/Currency/summary/getListData',
						queryParams: {
							gameAreaIdString: Currency.Summary.View.DataGrid.gameAreaCombogridInputContainer.combogrid('getValues').toString(),
							currencyTypeId: Currency.Summary.View.DataGrid.currencyTypeComboboxInputContainer.combobox('getValue'),
							startDate: Currency.Summary.View.DataGrid.startDateboxInputContainer.datetimebox('getValue'),
							endDate: Currency.Summary.View.DataGrid.endDateboxInputContainer.datetimebox('getValue'),
						}
					});
				},
			},
		},
	},
}